package com.maxatime.web.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.maxatime.common.constant.BusinessContents;
import com.maxatime.pojo.entity.UserInfo;
import com.maxatime.service.Ssbkaoshi7;

//五月份考试
@Controller
@RequestMapping("/Ssbcontroller7")
public class Ssbcontroller7 {

	@Autowired
	Ssbkaoshi7 ssbkaoshi7;
	/**
	 * 
	 * @Title: quest   
	 * @Description: TODO(查询)   
	 * @param: @param userInfo
	 * @param: @return      
	 * @return: Map<String,Object>      
	 * @throws   
	 * @author: ssb    
	 * @date:   2024年5月27日 上午10:39:26   
	 * @version V1.0
	 */
	//查询
	@RequestMapping("/quest")
	@ResponseBody
	public Map<String, Object> quest(@RequestBody UserInfo userInfo) {
		Map<String, Object> m = new HashMap<>();
		Map<String, Object> map = ssbkaoshi7.map(userInfo);
		m.put(BusinessContents.CODE, "0000");
		m.put(BusinessContents.MSG, "交易成功");
		m.put(BusinessContents.DATA, map.get("list"));
		m.put("pageInfo", map.get("pageInfo"));
		return m;
	}
	/**
	 * 
	 * @Title: add   
	 * @Description: TODO(新增)   
	 * @param: @param userInfo
	 * @param: @return      
	 * @return: Map<String,Object>        
	 * @throws   
	 * @author: ssb    
	 * @date:   2024年5月27日 上午10:39:39   
	 * @version V1.0
	 */
	//新增
	@RequestMapping("/add")
	@ResponseBody
	public Map<String, Object> add(@RequestBody UserInfo userInfo) {
		Map<String, Object> m = new HashMap<>();
		ssbkaoshi7.insertSelective(userInfo);
		m.put(BusinessContents.CODE, "1111");
		m.put(BusinessContents.MSG, "新增成功");
		return m;
	}
	/**
	 * 
	 * @Title: del   
	 * @Description: TODO(删除)   
	 * @param: @param jsonStr
	 * @param: @return      
	 * @return: Map<String,Object>      
	 * @throws   
	 * @author: ssb    
	 * @date:   2024年5月27日 上午10:39:47   
	 * @version V1.0
	 */
	//删除
	@RequestMapping("/del")
	@ResponseBody
	public Map<String, Object> del(@RequestBody String jsonStr) {
		JSONObject jsonObj = JSONObject.parseObject(jsonStr);
		int userId = jsonObj.getInteger("userId");
		Map<String, Object> m = new HashMap<>();
		ssbkaoshi7.deleteByPrimaryKey(userId);
		m.put(BusinessContents.CODE, "2222");
		m.put(BusinessContents.MSG, "删除成功");
		return m;
	}
	/**
	 * 
	 * @Title: find   
	 * @Description: TODO(反显)   
	 * @param: @param jsonStr
	 * @param: @return      
	 * @return: Map<String,Object>      
	 * @throws   
	 * @author: ssb    
	 * @date:   2024年5月27日 上午10:39:58   
	 * @version V1.0
	 */
	//反显
	@RequestMapping("/find")
	@ResponseBody
	public Map<String, Object> find(@RequestBody String jsonStr) {
		JSONObject jsonObj = JSONObject.parseObject(jsonStr);
		int userId = jsonObj.getInteger("userId");
		Map<String, Object> m = new HashMap<>();
		UserInfo find = ssbkaoshi7.find(userId);
		m.put(BusinessContents.CODE, "3333");
		m.put(BusinessContents.MSG, "find成功");
		m.put(BusinessContents.DATA, find);
		return m;
	}
	/**
	 * 
	 * @Title: update   
	 * @Description: TODO(修改)   
	 * @param: @param userInfo
	 * @param: @return      
	 * @return: Map<String,Object>      
	 * @throws   
	 * @author: ssb    
	 * @date:   2024年5月27日 上午10:40:25   
	 * @version V1.0
	 */
	//修改
	@RequestMapping("/update")
	@ResponseBody
	public Map<String, Object> update(@RequestBody UserInfo userInfo) {
		Map<String, Object> m = new HashMap<>();
		ssbkaoshi7.updateByPrimaryKeySelective(userInfo);
		m.put(BusinessContents.CODE, "4444");
		m.put(BusinessContents.MSG, "up成功");
		return m;
	}
}

